package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.common.constants.ArticleConstants;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @title: ArticleHomeController
 * @Author 椎名真白
 * @Date: 2022-06-11 18:16
 * @Version 1.0
 */

@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {

    /*
     * @description: 加载主页数据 返回ResponseResult 包含list集合
     * @author: 椎名真白
     * @date: 2022-06-11 19:54
     * @param: null
     * @return: null
     **/
    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("load")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto) {
        return apArticleService.load((short)3, articleHomeDto);
    }

    /*
     * @description: 更多文章信息
     * @author: 椎名真白
     * @date: 2022-06-12 11:23
     * @param: dto
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @PostMapping("/loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE, dto);
    }

    /**
     * @description: 最新文章信息
     * @author: 椎名真白
     * @date: 2022-06-12 11:23
     * @param: dto
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @PostMapping("/loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW, dto);
    }
}


